package com.example.provider.provider;

import com.example.custom.rpc.common.URL;
import com.example.custom.rpc.protocol.HttpServer;
import com.example.custom.rpc.register.LocalRegister;
import com.example.custom.rpc.register.MapRemoteRegister;
import com.example.provider.service.HelloServiceImpl;
import com.example.rpc.common.service.HelloService;
import org.springframework.stereotype.Component;

/**
 * @author liyuncong
 * @version 1.0
 * @file ServiceProvider
 * @brief ServiceProvider
 * @details ServiceProvider
 * @date 2022-11-02
 *
 * Edit History
 * ----------------------------------------------------------------------------
 * DATE                     NAME               DESCRIPTION
 * 2022-11-02               liyuncong          Created
 */
@Component
public class ServiceProvider {

    public static void main(String[] args) {
        new Thread(() -> {
            // 本地注册
            LocalRegister.register(HelloService.class.getName(), HelloServiceImpl.class);

            // 注册中心注册
            final URL url = new URL("localhost", 8082);
            MapRemoteRegister.register(HelloService.class.getName(), url);

            HttpServer httpServer = new HttpServer();
            httpServer.start(url.getHostname(), url.getPort());
        }).start();
    }

}
